//
//  NineViewController.m
//  UIComprehensive
//
//  Created by lanou3g on 16/1/28.
//  Copyright © 2016年 徐强. All rights reserved.
//

#import "NineViewController.h"

@interface NineViewController ()

@end

@implementation NineViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"九宫格";

    //九宫格宽度
#define kAppViewW 80
    //九宫格高度
#define kAppViewH 80
    //每行个数
#define kColCount 3
    //每行的Y值的基准值
#define kBaseY 10
    //列间距
    CGFloat marginX = (kScreenWidth-kColCount *kAppViewW)/(kColCount +1);
    //行间距
    CGFloat marginY = 30;
    for (int i = 0 ; i < 15; i++) {
        //行
        int row = i / kColCount;
        //列
        int col = i %kColCount;
        
        CGFloat x = marginX +col *(marginX +kAppViewW);
        CGFloat y = kBaseY + marginY +row * (marginY +kAppViewH);
        
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(x, y, kAppViewW, kAppViewH)];
        view.backgroundColor = [UIColor yellowColor];
        [self.view addSubview:view];
        
        //格子内部
        
    }


    
}




@end
